package com.minarto.utils {
	import flash.utils.Dictionary;
	import de.polygonal.core.ObjectPool;


	/**
	 * @author KIMMINHWAN
	 */
	public class GPool {
		static private var	_dic:Dictionary = new Dictionary(true);

		
		static public function addPool($class:Class, $size:uint = 1):ObjectPool {
			return	_dic[$class] || _createPool($class, $size || 1);
		}
		
		
		static private function _createPool($class:Class, $size:uint):ObjectPool {
			var p:ObjectPool = new ObjectPool(true);
			p.allocate($size, $class);
			
			_dic[$class] = p;
			
			return	p;
		}
		
		
		static public function getPool($class:Class):ObjectPool {
			return	_dic[$class] || _createPool($class, 1);
		}
		
		
		static public function delPool($class:Class):void {
			var p:ObjectPool = _dic[$class];
			if(p)	p.deconstruct();
			
			delete _dic[$class];
		}
	}
}